home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************/
- /* */
- /* TurboCAD for Windows */
- /* Copyright (c) 1993 - 1999 */
- /* International Microcomputer Software, Inc. */
- /* (IMSI) */
- /* All rights reserved. */
- /* */
- /******************************************************************/
- // ToolList.cpp : implementation file
- //
-
- #include "stdafx.h"
- #include "InsSmObj.h"
- #include "ToolList.h"
- #include "SdiDialog.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CToolList
-
- CToolList::CToolList()
- {
- }
-
- CToolList::~CToolList()
- {
- }
-
-
- BEGIN_MESSAGE_MAP(CToolList, CListBox)
- //{{AFX_MSG_MAP(CToolList)
- ON_WM_MOUSEMOVE()
- ON_WM_LBUTTONUP()
- ON_CONTROL_REFLECT(LBN_SELCHANGE, OnSelchange)
- ON_WM_LBUTTONDOWN()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CToolList message handlers
-
- void CToolList::OnMouseMove(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
- if(nFlags & MK_LBUTTON)
- {
-
- int dx = m_LB_DOWNpoint.x - point.x;
- int dy = m_LB_DOWNpoint.y - point.y;
- CPoint Pt = point;
-
- if((abs(dx) > 1 || abs(dy) > 1) && m_drag)
- {
- // if dragging
- if (((CSdiDialog*)GetParent())->m_dwEventConnection == 0)
- {
- ((CSdiDialog*)GetParent())->ConnectEvents();
- }
- m_OldCursor = GetCursor();
- m_NewCursor = LoadCursor(AfxGetInstanceHandle( ), MAKEINTRESOURCE(IDC_CURSOR1));
- SetCursor(m_NewCursor);
- ShowCursor(TRUE);
- m_drag = FALSE;
- m_LB_DOWNpoint.x = -1;
- m_LB_DOWNpoint.y = -1;
- ((CSdiDialog*)GetParent())->m_FirstClick = TRUE;
- return;
-
- }
-
- ClientToScreen(&Pt);
- CWnd *pClickWNd = WindowFromPoint(Pt);
-
- if(pClickWNd && pClickWNd != this)
- {
- pClickWNd->ScreenToClient(&Pt);
- pClickWNd->PostMessage(WM_MOUSEMOVE, nFlags, MAKELONG(Pt.x, Pt.y));
- }
-
- }
- }
-
-
-
- void CToolList::OnLButtonUp(UINT nFlags, CPoint point)
- {
- CListBox::OnLButtonUp(nFlags, point);
- m_drag = FALSE;
-
- CPoint Pt = point;
- ClientToScreen(&Pt);
- CWnd *pClickWNd = WindowFromPoint(Pt);
-
- if(pClickWNd && pClickWNd != this)
- {
- pClickWNd->ScreenToClient(&Pt);
- pClickWNd->PostMessage(WM_LBUTTONUP, nFlags, MAKELONG(Pt.x, Pt.y));
- SetCursor(m_OldCursor);
- ShowCursor(TRUE);
- return;
-
- }
- else
- {
- SetCursor(m_OldCursor);
- ShowCursor(TRUE);
-
- }
- }
-
-
- void CToolList::OnSelchange()
-
- {
- // TODO: Add your control notification handler code here
-
-
- CListBox *pList = (CListBox *) (GetParent()->GetDlgItem(IDC_LIST1));
-
- HCURSOR hOC = ::SetCursor(::LoadCursor(NULL,IDC_WAIT));
-
- int index = pList->GetCurSel();
- CString cstrSelected;
-
- pList->GetText(index, cstrSelected);
- if (m_cstrCurSelected != cstrSelected) // check if the current selection is changed
- {
- CViewWnd *m_wndView = (CViewWnd *) (((CSdiDialog*)GetParent())->GetDlgItem(IDC_PREVIEW));
- m_wndView->Clear();
-
- m_wndView->DoPreview();
- m_cstrCurSelected = cstrSelected;
- m_wndView->Invalidate();
- }
- ::SetCursor(hOC);
-
- }
-
- void CToolList::OnLButtonDown(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
-
- BOOL ret;
-
- CListBox::OnLButtonDown(nFlags, point);
- m_drag = TRUE;
- m_LB_DOWNpoint.x = point.x;
- m_LB_DOWNpoint.y = point.y;
-
- CString cstrSelected;
-
- GetText(ItemFromPoint(point, ret), cstrSelected);
-
- if (m_cstrCurSelected != cstrSelected) // check if the current selection is changed
- {
- BeginWaitCursor();
- CViewWnd *m_wndView = (CViewWnd *) (((CSdiDialog*)GetParent())->GetDlgItem(IDC_PREVIEW));
- m_wndView->Clear();
-
- m_wndView->DoPreview();
- m_cstrCurSelected = cstrSelected;
- m_wndView->Invalidate();
- EndWaitCursor();
- }
-
- }
-